<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<c:import url="/head.jsp"></c:import>
<script
	src="<%=request.getContextPath()%>/scripts/My97DatePicker4/WdatePicker.js"></script>
<script src="<%=request.getContextPath()%>/scripts/submitcheck.js"></script>
<c:import url="/deptselectInner.jsp"></c:import>
<script src="<%=request.getContextPath()%>/scripts/jquery.form.js"></script>
<script type="text/javascript">
String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
};

function bopt( k ){
	document.getElementById("opt").value = k ;
}
var f = null;

function check(formData, jqForm, options) {

	if (f.proName.value == ""){
		alert("必须填写项目名称");
		f.proName.focus();
		return false;
	}
	
	var patrn=/^[0-9]{0,7}(\.[0-9]{0,3}){0,1}$/;
	if(f.totalPrice.value == ""){
		alert("必须填写项目总金额");
		return false;
	}
	if(!patrn.exec(f.totalPrice.value)){
		alert("请正确填写项目总金额");
		return false;
	}
	
	if (f.proAuditDepartment && f.proAuditDepartment.value == ""){
		alert("必须选择编码、审批部门");
		return false;
	}
	
	<c:if test="${projectAuditInfo.proCode==null}">
	if (f.proAuditYear && f.proAuditYear.value == ""){
		alert("必须选择立项年份");
		return false;
	}
	</c:if>
	if (f.opt.value=='3'){
		f.rejectReason.value = f.rejectReason.value.trim();
		if (f.rejectReason.value==''){
			f.rejectReason.focus();
			alert("审核未通过时必须填写审核未通过意见");
			return false;
		}
	}
	
	if(f.proAuditDepartment.value.substring(8,9)<2){
		alert(f.proAuditDepartmentShow.value+"不能选做审批部门，请选择具体的审批部门");
		return false;
	}


	return true;
}

function localResultResponse(data,status) {

	if(status=="success"){

		document.getElementById('proCode').value = data.msg; //将返回的新项目编号显示在本页
		parent.setProCode(data.msg) ; //设置左边IFRAME中的proCode，用于修改提交链接
	}
	var oldid = $('#newId').val();
	resultResponse(data,status);
	var newid = $('#newId').val();
	if (oldid == 0 && newid > 0){
		$('#proCode').val(data.msg);
		parent.openPro(data.msg,1);
		parent.showPro(1,true);
	}
}

${initPro};

function unshowProCode()
{
	$('#proCode').css('display','none');
}

//弹出新窗口的JS 
function openNewWin(owurl){
	var tmp=window.open("about:blank","","");
	tmp.focus();
	tmp.location=owurl;
}
</script>
<body leftmargin="0" rightmargin="0" topmargin="0" ${projectAuditInfo.proCode == null?"onload='unshowProCode()'":""}>
<form id="form1" name="form1" method="post" action="<c:url value="/admin/editopt/"/>"  onsubmit="return false">
<c:import url='${depeId==0?"form.jsp":"depform.jsp"}'></c:import>
<table align="center" width="100%" id="optbtn">
	<tr>
		<td align="center" >
		<input type="hidden" id="newId" value="${projectAuditInfo.proAuditID}"/>
		<input type="hidden" id="opt" name="opt" /> 
		
		<c:if test="${show == 1}">
			<input type="submit" value="保  存" onclick="bopt(1)" class="bnt60" />
		</c:if>
		
		</td>
	</tr>
</table>
<table align="center" width="100%">
	<tr>
		<td align="right" ><span style="font-size: 13px;">填表说明：<font color="red">*</font>为必须内容</span></td>
	</tr>
</table>
</form>
<script type="text/javascript">

window.onload=function (){

	f = document.getElementById("form1");

	var options={type:"POST", dataType:"json", beforeSubmit:check, success:localResultResponse};
	$('#form1').ajaxForm(options);
}

</script>
</body>
</html>
